package cn.com.zsw.gblog.modules.user.service.impl;

import cn.com.zsw.gblog.modules.user.entity.GbUserRoleEntity;
import cn.com.zsw.gblog.modules.user.mapper.UserRoleMapper;
import cn.com.zsw.gblog.modules.user.service.GbUserRoleService;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * (gb_sys_user)表服务实现类
 *
 * @author shiwangzhou
 * @since 2020-09-17 16:50:14
 */
@Service
public class GbUserRoleServiceImpl extends ServiceImpl<UserRoleMapper, GbUserRoleEntity> implements GbUserRoleService {
    @Resource
    UserRoleMapper userRoleMapper;


    @Override
    public void setRole(Long userId, Long roleId) {
        GbUserRoleEntity gbUserRoleEntity = new GbUserRoleEntity();
        gbUserRoleEntity.setId(IdUtil.createSnowflake(1,1).nextId());
        gbUserRoleEntity.setRoleId(roleId);
        gbUserRoleEntity.setUserId(userId);
        gbUserRoleEntity.setCreateTime(new Date());
        gbUserRoleEntity.setUpdateTime(new Date());
        gbUserRoleEntity.setStatus(1);
        userRoleMapper.insert(gbUserRoleEntity);
    }
}